using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using OgilvyOne.Model;
using OgilvyOne.BLL;

namespace OgilvyOne.ProcessFlow
{
    public class MenuFuncController
    {
        // Fields
      //  private const string URL_CHECKLOGIN = "func_checklogin.aspx";
        private const string URL_DEFAULT = "/systemmanage/module/module_list.aspx";
       //  private const string URL_MEMBERCREATE = "func_list.aspx";
       // private const string URL_MEMBERUPDATE = "func_modify.aspx";

        // Methods
        public bool CreateFunc(string[] menu_uid, int ifunc_uid, string sSWF)
        {
            try
            {
                MenuFunc func = new MenuFunc();
                func.DeleteMenuList(ifunc_uid);
                if (menu_uid != null)
                {
                    for (int i = 0; i < menu_uid.Length; i++)
                    {
                        MenuFuncInfo info = new MenuFuncInfo(int.Parse(menu_uid[i]), ifunc_uid, sSWF);
                        func.Insert(info);
                    }
                }
                HttpContext.Current.Response.Redirect(URL_DEFAULT, true);
            }
            catch
            {
                return false;
            }
            return true;
        }

        public void UpdateMenuFunc(MenuFuncInfo updatedMenuFuncInfo)
        {
            new MenuFunc().Update(updatedMenuFuncInfo);
            HttpContext.Current.Response.Redirect(URL_DEFAULT, true);
        }

    }
}
